
#include <iostream>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>



using namespace std;

class tclock
{
public:
    tclock()
    {
        time_t t = time(NULL);
        tm local = *localtime(&t);
        thour = local.tm_hour;
        tmin  = local.tm_min;
        tsecond = local.tm_sec;
    }
    void run()
    {
        while(1)
        {   
            tick();
            show();
        }
    }
    void display()
    {
        cout<<thour<<":"<<tmin<<":"<<tsecond<<endl;
    }

private:
    void tick()
    {
        sleep(1);
        if(++tsecond == 60) //60s
        {
            tsecond = 0;
            if(++tmin == 60) //60min
            {
                tmin = 0;
                if(++thour == 24) //24hour
                {
                    thour = 0;
                    cout<<"one day..."<<endl;
                }
            }
        }
    }
    void show()
    {
        system("clear");
        cout<<thour<<":"<<tmin<<":"<<tsecond<<endl;
    }
    int thour;
    int tmin;
    int tsecond;
};


int main(void)
{
    tclock clo;
    
    clo.run();
    
    return 0;
}

